home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / vdigit.zip / TSR.ASM < prev    next >
Assembly Source File  |  1989-06-24  |  4KB  |  166 lines

  1. ;**************************************************************
  2. ;*                                                            *
  3. ;*          Digitized Voice Programmer's Toolkit              *
  4. ;*          ------------------------------------              *
  5. ;*                                                            *
  6. ;*            Example memory-resident program                 *
  7. ;*                                                            *
  8. ;*          Copyright (c) 1989, Farpoint Software             *
  9. ;*                                                            *
  10. ;*                                                            *
  11. ;*  This program monitors the state of the left shift key     *
  12. ;*  bit at absolute address 417h (bit 1). Upon detecting a    *
  13. ;*  zero to one transition of this bit, a voice announcement  *
  14. ;*  is initiated in the background.                           *
  15. ;*                                                            *
  16. ;**************************************************************
  17.  
  18. .286
  19. .MODEL LARGE
  20. DOSSEG
  21.  
  22. shift_mask equ    02h
  23.  
  24. extrn    PVOICE_INIT:far
  25. extrn    PVOICE_START:far
  26. extrn    PVOICE_STATUS:far
  27.  
  28. ;------------------------------------------------
  29.  
  30. ;declare the VDATA segment here as well as in TSRVM.ASM
  31. ; so that the pointers to the beginning and end of the
  32. ; voice data can be properly accessed
  33.  
  34. VDATA    segment    public 'VDATA'
  35.  
  36. extrn    _EVMSG:byte
  37. extrn    _EVMSGLEN:byte
  38.  
  39. VDATA    ends
  40.  
  41. ;------------------------------------------------
  42.  
  43. .STACK    256
  44.  
  45. ;------------------------------------------------
  46.  
  47. .DATA
  48.  
  49. count    dd    0
  50. index    dd    0
  51. pspseg    dw    0
  52. prev    db    0
  53.  
  54. ;------------------------------------------------
  55.  
  56. .CODE
  57.     assume    ds:DGROUP
  58.  
  59. old_1C    dd    0    ;this is in the code segment so
  60.             ; that we can jump to the original
  61.             ; user timer tick routine without
  62.             ; inconvenient messing with the stack
  63.  
  64. ; - - - - - - - - - - - - - - - - - - - - - - - -
  65.  
  66. ;this is the user timer tick interrupt routine
  67.  
  68. shift_check    proc    far
  69.  
  70.     push    ds    ;save all registers
  71.     push    es
  72.     pusha
  73.  
  74.     mov    ax,DGROUP
  75.     mov    ds,ax
  76.  
  77.     mov    ax,40h
  78.     mov    es,ax
  79.     mov    al,es:[17h]    ;address at which shift state is kept
  80.     and    al,shift_mask
  81.     cmp    al,prev            ;has the bit changed?
  82.     je    shift_check_exit
  83.     mov    prev,al
  84.     cmp    al,shift_mask        ;is it now a 1?
  85.     jne    shift_check_exit
  86.  
  87. ;left shift has been pressed
  88. ;are we still playing message from last press?
  89.  
  90.     push    ds
  91.     push    offset count
  92.     push    ds
  93.     push    offset index
  94.     call    PVOICE_STATUS
  95.     or    ax,ax
  96.     jnz    shift_check_exit
  97.  
  98. ;trigger voice message playback
  99.  
  100.     push    VDATA            ;block address
  101.     push    offset _EVMSG
  102.  
  103.     mov    ax,offset _EVMSGLEN
  104.     sub    ax,offset _EVMSG
  105.     push    0            ;block    length
  106.     push    ax
  107.  
  108.     push    0            ;file read flag (MUST be zero!)
  109.  
  110.     push    0            ;handle
  111.  
  112.     push    0            ;data length
  113.     push    ax
  114.  
  115.     push    0            ;start position
  116.     push    0
  117.  
  118.     call    PVOICE_START        ;do it
  119.  
  120. shift_check_exit:
  121.     popa        ;restore all registers
  122.     pop    es
  123.     pop    ds
  124.     jmp    old_1C    ;chain to previous holder of this vector
  125.  
  126. shift_check    endp
  127.  
  128. ; - - - - - - - - - - - - - - - - - - - - - - - -
  129.  
  130. ;Begin execution here
  131.  
  132. start:    mov    ax,DGROUP    ;set segment registers
  133.     mov    ds,ax
  134.     mov    ax,es
  135.     mov    pspseg,ax    ;save PSP segment for later
  136.  
  137. ;install voice playback routines
  138.  
  139.     call    PVOICE_INIT
  140.  
  141. ;get the original user timer tick vector
  142.  
  143.     mov    ax,351Ch
  144.     int    21h
  145.     mov    word ptr old_1C,bx
  146.     mov    word ptr old_1C+2,es
  147.  
  148. ;set the vector to point to our routine
  149.  
  150.     push    ds
  151.     lea    dx,shift_check
  152.     mov    ax,cs
  153.     mov    ds,ax
  154.     mov    ax,251Ch
  155.     int    21h
  156.     pop    ds
  157.  
  158. ;terminate and stay resident
  159.  
  160.     mov    dx,ss        ;DOSSEG forces stack to last segment
  161.     sub    dx,pspseg    ;compute amout of memory this occupies
  162.     mov    ax,3100h    ;terminate and stay resident
  163.     int    21h
  164.  
  165.     end    start
  166.